/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package epibot.testeProteinas;

import epibot.BancoDeDados.ArmazenaDados.Fasta;
import epibot.GUI.FramePrincipal;
import java.util.ArrayList;

/**
 *
 * @author Rafael Tosta
 */
public class JPanelBuscaRobot extends javax.swing.JPanel {

    private FramePrincipal fp;
    private ArrayList<Fasta> fastas;
    private ArrayList<String> motores;
    private JPanelTesteProteinas jp;
    private String tamanho;
    private String alelo;
    private String nomeDaCalibragem;
    GerenciadorRobot_Teste g = null;

    /**
     * Creates new form NewJPanelBusca
     */
    public JPanelBuscaRobot(FramePrincipal fp, ArrayList<Fasta> fastas, ArrayList<String> motores, String tamanho, String alelo, String nomeDaCalibragem) {
        initComponents();
        this.fp = fp;
        this.fastas = fastas;
        this.motores = motores;
        this.tamanho = tamanho;
        this.alelo = alelo;
        this.nomeDaCalibragem = nomeDaCalibragem;

        iniciaBuscas();
    }

    private void iniciaBuscas() {
        g = new GerenciadorRobot_Teste();
        g.set(fastas, motores, this, tamanho, alelo, nomeDaCalibragem);
        g.start();
    }

    public void iniciaPBar(int max) {
        jProgressBar.setMaximum(max);
        jProgressBar.setValue(0);
    }

    public void setValuePBar(int v) {
        jProgressBar.setValue(v);
    }

    public void setjTextArea(String text) {
        this.printQuery.append(text + "\n");
        printQuery.setCaretPosition(printQuery.getDocument().getLength());
    }

    public void telainicial() {
        fp.atualizaFrame();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        printQuery = new javax.swing.JTextArea();
        jButtonCancel = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jProgressBar = new javax.swing.JProgressBar();

        printQuery.setEditable(false);
        printQuery.setColumns(20);
        printQuery.setRows(5);
        printQuery.setBorder(javax.swing.BorderFactory.createTitledBorder("Query"));
        jScrollPane1.setViewportView(printQuery);

        jButtonCancel.setText("Cancel");
        jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 48)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(204, 204, 204));
        jLabel1.setText("EPIBOT");

        jLabel2.setForeground(new java.awt.Color(204, 204, 204));
        jLabel2.setText("Discovery Epitope");

        jProgressBar.setStringPainted(true);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(392, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(44, 44, 44)
                        .addComponent(jLabel2)))
                .addGap(383, 383, 383))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButtonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jProgressBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 383, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addGap(42, 42, 42)
                .addComponent(jButtonCancel)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
        if (g != null) {
            g.stop();
        }
        telainicial();
    }//GEN-LAST:event_jButtonCancelActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCancel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JProgressBar jProgressBar;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea printQuery;
    // End of variables declaration//GEN-END:variables
}
